﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyCourseManageProject.Bll;
using MyCourseManageProject.Model;
using System.Collections.Generic;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitCourseManage
    {
        private CoursesBll cbll = new CoursesBll();
        [TestMethod]
        //测试课程添加类
        public void TestAddCourse()
        {
            //1定义期望值
            bool expected = true;
            //2封装对象
            Courses cs = new Courses()
            {
                
                CourseName = "测试课程名称",
                CourseCountent = ".net全栈开发",
                ClassHour = 500,
                Credit = 20,
                CategoryId = 10,
                TeacherId = 1001,
                TeacherName = "后端"
            };
            //3获取实际值
            string msg = "测试UpdateCourses方法";
            bool actual = cbll.AddCourses(cs, out msg);
            //4正式测试  Assert.AreEqual(期望值, 实际值, msg)
            Assert.AreEqual(expected, actual, "测试AddCourse方法出错!");

        }
        //测试课程查询类
        public void TestGetAll()
        {

            //定义期望值
            int categroyId = 10;
            string courseName = ".Net课程";
            List<Courses> clist = cbll.GetAll(categroyId, courseName);
            if (clist==null)
                Console.WriteLine("GetAll方法未测试通过");
            
        }
        //测试课程修改类
        public void TestUpdateCourse()
        {
            //1定义期望值
            bool expected = true;
            //2封装对象
            Courses cs = new Courses()
            {
                CourseId = 1000,
                CourseName = "测试课程名称",
                CourseCountent = ".net全栈开发",
                ClassHour = 500,
                Credit = 20,
                CategoryId = 10,
                TeacherId = 1001,
                TeacherName = "后端"
            };
            //3获取实际值
            string msg = "测试UpdateCourses方法";
            bool actual = cbll.UpdateCourses(cs, out msg);
            //4正式测试  Assert.AreEqual(期望值, 实际值, msg)
            Assert.AreEqual(expected, actual, "测试UpdateCourses方法出错!");
        }
    }
}
